package com.ruoyi.mall.product.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.valid.AddGroup;
import com.ruoyi.common.core.valid.Status;
import com.ruoyi.common.core.valid.UpdateGroup;
import com.ruoyi.common.core.valid.UpdateStatusGroup;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌对象 pms_brand
 *
 * @author zhangqishu
 * @date 2022-05-25
 */
public class PmsBrand {
    private static final long serialVersionUID = 1L;

    /**
     * 品牌id
     * 新增的时候id为空 使用@Null注解
     * 修改的时候id不为空 使用@NotNull注解
     */
    @Null(message = "新增不能指定id", groups = {AddGroup.class})
    @NotNull(message = "修改需要指定id", groups = {UpdateGroup.class})
    private Long id;

    /**
     * 品牌名
     */
    @Excel(name = "品牌名")
    @NotBlank(message = "品牌名必须提交", groups = {AddGroup.class, UpdateGroup.class})
    private String name;

    /**
     * 品牌logo
     */
    @Excel(name = "品牌logo")
    @URL(message = "logo必须是一个合法的url地址", groups = {AddGroup.class, UpdateGroup.class})
    @NotBlank(message = "logo不能为空", groups = {AddGroup.class})
    private String logo;

    /**
     * 显示状态[0-不显示；1-显示]
     */
    @Excel(name = "显示状态[0-不显示；1-显示]")
    @NotNull(groups = {AddGroup.class, UpdateStatusGroup.class})
    @Status(value = {0, 1}, groups = {AddGroup.class, UpdateStatusGroup.class})
    private Integer status;


    /**
     * 检索首字母
     */
    @Excel(name = "检索首字母")
    @NotBlank(message = "logo不能为空", groups = {AddGroup.class})
    @Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须是一个字母", groups = {AddGroup.class, UpdateGroup.class})
    private String firstLetter;

    /**
     * 排序
     */
    @Excel(name = "排序")
    @Min(value = 0, message = "排序必须大于等于0", groups = {AddGroup.class, UpdateGroup.class})
    @NotNull(groups = {AddGroup.class})
    private Long sort;

    /**
     * 描述
     */
    @Excel(name = "描述")
    private String remark;

    /**
     * 检索条件
     */
    @TableField(exist = false)
    private String key;

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public String getLogo() {
        return logo;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getStatus() {
        return status;
    }

    public void setFirstLetter(String firstLetter) {
        this.firstLetter = firstLetter;
    }

    public String getFirstLetter() {
        return firstLetter;
    }

    public void setSort(Long sort) {
        this.sort = sort;
    }

    public Long getSort() {
        return sort;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("name", getName())
                .append("logo", getLogo())
                .append("status", getStatus())
                .append("firstLetter", getFirstLetter())
                .append("sort", getSort())
                .append("remark", getRemark())
                .append("key", getKey())
                .toString();
    }
}
